var empList  =  [
                {
                    empId :"6566",
                    empImg:"img/2.png",
                    empName:"张三",
                    position:"总经理"
                },{
                    empId :"AAT",
                    empImg:"img/2.png",
                    empName:"李四",
                    position:"总经理"
                }
            ],
            empDeptList = [
                {
                    deptImg:"img/2.png",
                    deptName:"技术支持中心"
                },{
                    deptImg:"img/2.png",
                    deptName:"产品部"
                },{
                    deptImg:"img/2.png",
                    deptName:"全面预算事业部",
                    lower : true
                }                 
            ]
var dept = null;
jq(document).ready(function(){
    initPageDept();
    initPageName();
});
function initPageName(){
    Supp.IndexedList.init({
        renderTo:"list", //id
        url:"data/empIndexedList.json", 
        chkStyle:"radio",   //radio/checkbox 
        hasImg : true,
        callBack:function(){
            $(".supp-table-view .supp-list-content").click(function(){
                var val = $(this).parent().find("input").prop("checked");
                var empId = $(this).parent().find("input").val();
                var item = null;
                for (var i=0;i<dept.empList.length;i++) {
                    if (empId == dept.empList[i].empId) {
                        item = dept.empList[i];
                        dept.selectedRow(item.empId,item.empName);
                    }
                }                   
                     
            });            
        }    
    });
}
function initPageDept(){
    dept = new Vue({
        el : "#empDept",
        data : {
            empList : empList,
            empDeptList : empDeptList
        },
        computed : {
            empTotal : function(){
                return this.empList.length + this.empDeptList.length;
            }
        },
        methods : {
            selectedRow : function(id,deptName){
                var returnVal = {};
                returnVal["empName"] = deptName;
                returnVal["empId"] = id;
              
                appcan.window.publish("empTree",returnVal);               
                appcan.window.close();
            },
            showLowerBtn : function(item){
                this.empDeptList = [
                    {
                        id : "1",
                        deptImg : "img/2.png",
                        deptName : "业务一部",
                        lower : false
                    },
                    {
                        id : "2",
                        deptImg : "img/2.png",
                        deptName : "业务二部"
                    } 
                ];  
                                  
            },
            returnsuper : function(index,deptId){
                if (index == app1.crumbsList.length-1) {
                    return false;
                }

                app1.deptList = [
                {
                    id : "1",
                    deptImg : "img/2.png",
                    deptName : "产品部"
                },
                {
                    id : "2",
                    deptImg : "img/2.png",
                    deptName : "全面预算事业部"
                }
                ];    
                app1.showCrumbs = false;         
            }
        }
    });
}
